<%@page import="beans.Query"%>
<%@page import="java.util.ArrayList"%>
<%@page import="beans.Words"%>
<%@page language="Java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Wyszukiwarka drużyn</title>
<link rel="stylesheet" href="css/css.css" type="text/css" />
</head>
<body>
	<div id = "all">
		<div id = "header"><h1>Wyszukiwarka drużyn</h1> </div>
		<div id = "content">
			<% ArrayList<Query> queries = (ArrayList<Query>)session.getAttribute("queries"); %>
			
			<% for(int i = 0 ; i < queries.size() ; i++) { 
				Query q = queries.get(i);
			%>
				<%=i+1 +". "+ q.getQuantifier() + " " + q.getWord()%>
				<INPUT TYPE="button" value="Usun" onClick="parent.location='PortalEntry?do=delete&id=<%=i %>'">
				</br>	
			<% } %>
			
			<form method="post" action="PortalEntry?do=add">
				<% Words words = new Words(); %>
				<select name="quantifier">
					<%for(String quantifier :  words.getQuantifiers()) { %>
			  			<option
			  			value="<%=quantifier %>"><%=quantifier %></option>
			  		<%} %>
				</select>
				<select name="word">
					<%for(String word :  words.getWords()) { %>
			  			<option
			  			value="<%=word %>"><%=word %></option>
			  		<%} %>
				</select>
				<button type="submit">Dodaj</button>
			</form>
			
			<br/>
			<INPUT TYPE="button" value="Szukaj" onClick="parent.location='PortalEntry?do=search'">
			<br/>
			<table border = "1">
				<%
					ArrayList<String> results = (ArrayList<String>)session.getAttribute("results");
					if(results == null)
						results = new ArrayList<String>();
					int i = 1;
					for(String str : results) {
					%>
					<tr>
						<td><%= i++ +". "%></td><td><%=  str %></td>
					<tr>
					<% } %>
			</table>
		</div>
		<div id = "footer">
			Autorzy: Paweł Krakowiak, Marcin Haręza, Marcin Kaczor, Maciej Koch
		</div>
	</div>	
</body>
</html>